<?php
/**
 * 短信模型
 * @author cjli
 *
 */
class SmsCodeModel extends Model{
	
	//根据IP获取当天发送条数
	public function get_today_count_by_ip($ip){
		$discount =  D('sms_code')->field('COUNT(distinct mobile) AS num')->where(array('ip' => $ip,'type'=>'register','created'=>array('EGT',strtotime('today'))))->find();
		return $discount['num'];
	}
   	
	public static function get_today_count_by_phone($phone,$type){
		$discount = D('sms_code')->field('COUNT(distinct mobile) AS num')->where(array('mobile' => $phone,'type'=>$type,'created'=>array('EGT',strtotime('today'))))->find();
		return $discount['num'];
	}
   
	public static function add_do($data){
		if($last_id=D('sms_code')->add($data)){
			return $last_id;
		}else{
			return false;	
		}
	}
}